﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace University.Workshop.WinApp.HospitalizationFolder
{
    public partial class SearchHospitalizationForm : Form
    {
        public SearchHospitalizationForm()
        {
            InitializeComponent();
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void SearchHospitalizationForm_Load(object sender, EventArgs e)
        {
            hospitalizationGridView.DataSource = Business.HospitalizationManager.ObtainActiveHospitalizations();
        }

        private void hospitalizationGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var selected = hospitalizationGridView.SelectedCells[0].RowIndex;

            try 
            {
                int hospitalizationId = int.Parse(hospitalizationGridView.Rows[selected].Cells[0].Value.ToString());
                HospitalizationFolder.HospitalizationManagementForm form = new HospitalizationManagementForm(hospitalizationId);
                form.ShowDialog();
                this.Close();
            }
            catch(NullReferenceException)
            {}
        }

        private void btnAddMedicine_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void hospitalizationGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
